package com.zhangmeng.online.exam.ui.components;

import javafx.beans.property.SimpleStringProperty;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;

/**
 * @author zm
 * @date 2025/3/20 11:26
 * @version: 1.0
 */
public class ExamResultHeaderComponent extends HBox {

    private SimpleStringProperty examCount = new SimpleStringProperty("试题数量：0");//试题数量

    private Button commitBtn;//提交按钮

    public ExamResultHeaderComponent(double spacing) {
        super();
        this.setSpacing(spacing);
        Label label = new Label("");
        label.setPadding(new Insets(5, 0, 0, 0));
        label.textProperty().bindBidirectional(examCount);

        commitBtn = new Button("提交");
        this.setPadding(new Insets(0, 20, 0, 0));

        // 创建一个占位填充区域（关键修改）
        Region spacer = new Region();
        HBox.setHgrow(spacer, Priority.ALWAYS); // 允许区域横向扩展

        this.getChildren().add(label);
        this.getChildren().add(spacer);
        this.getChildren().add(commitBtn);

    }

    public Button getCommitBtn() {
        return commitBtn;
    }

    public void setCommitBtn(Button commitBtn) {
        this.commitBtn = commitBtn;
    }

    public String getExamCount() {
        return examCount.get();
    }

    public SimpleStringProperty examCountProperty() {
        return examCount;
    }

    public void setExamCount(String examCount) {
        this.examCount.set(examCount);
    }
}
